package com.letv.work;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import com.letv.bean.SummaryBean;
import com.letv.conf.ConfigFactory;
import com.letv.mail.MailSenderInfo;
import com.letv.mail.SimpleMailSender;

public abstract class AbstarctWorkJob {

    protected static final String TEXT_MESSAGE_ISOPEN = ConfigFactory.getString("textMessage.isopen");

    protected static final int TEXT_MESSAGE_WARN_DETAIL = ConfigFactory.getInt("textMessage.warnDetail", 1000000);

    protected static final int TEXT_MESSAGE_WARN_WEBSITE = ConfigFactory.getInt("textMessage.warnWebsite", 1000000);

	public abstract SummaryBean work(String type);


	public void sendMail(String content) {
		SimpleMailSender sms = SimpleMailSender.getInstance();
		MailSenderInfo mailInfo = new MailSenderInfo();
		mailInfo.setSubject(ConfigFactory.getString("mail.subject"));
		mailInfo.setContent(content);

		try {
			sms.send(mailInfo);
		} catch (AddressException e) {
			e.printStackTrace();
		} catch (MessagingException e) {
			e.printStackTrace();
		}
	}

	public void sendMail(MailSenderInfo mailInfo) {
		SimpleMailSender sms = SimpleMailSender.getInstance();

		try {
			sms.send(mailInfo);
		} catch (AddressException e) {
			e.printStackTrace();
		} catch (MessagingException e) {
			e.printStackTrace();
		}
	}
}
